]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/network: Use ActiveConnection:state in VPN item
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 2 Aug 2022 09:46:28 +0000 (11:46 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sun, 7 Aug 2022 20:41:09 +0000 (22:41 +0200)
The separate :vpn-state property is more fine-grained, but as
we aren't using anything beyond what :state provides, we can
just as well use that.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>

js/ui/status/network.js

index 547dadc361a7c8627b8850d5f68c3a9df2529184..64f44a93ec4057cdb188755d1b35d76dbc1ec5f9 100644 (file)
@@ -1437,13 +1437,6 @@ var NMWireguardItem = class extends NMConnectionItem {
 };
 
 var NMVpnConnectionItem = class extends NMConnectionItem {
-    isActive() {
-        if (this._activeConnection == null)
-            return false;
-
-        return this._activeConnection.vpn_state != NM.VpnConnectionState.DISCONNECTED;
-    }
-
     _buildUI() {
         this.labelItem = new PopupMenu.PopupMenuItem('');
         this.labelItem.connect('activate', this._toggle.bind(this));
@@ -1459,29 +1452,22 @@ var NMVpnConnectionItem = class extends NMConnectionItem {
         this.emit('icon-changed');
     }
 
-    _connectionStateChanged(ac, newstate, reason) {
-        if (newstate === NM.VpnConnectionState.FAILED &&
-            reason !== NM.VpnConnectionStateReason.NO_SECRETS)
+    _connectionStateChanged() {
+        const state = this._activeConnection?.get_state();
+        const reason = this._activeConnection?.get_state_reason();
+
+        if (state === NM.ActiveConnectionState.DEACTIVATED &&
+            reason !== NM.ActiveConnectionStateReason.NO_SECRETS &&
+            reason !== NM.ActiveConnectionStateReason.USER_DISCONNECTED)
             this.emit('activation-failed');
 
         this.emit('icon-changed');
         super._connectionStateChanged();
     }
 
-    setActiveConnection(activeConnection) {
-        this._activeConnection?.disconnectObject(this);
-
-        this._activeConnection = activeConnection;
-
-        this._activeConnection?.connectObject('vpn-state-changed',
-            this._connectionStateChanged.bind(this), this);
-
-        this._sync();
-    }
-
     getIndicatorIcon() {
         if (this._activeConnection) {
-            if (this._activeConnection.vpn_state < NM.VpnConnectionState.ACTIVATED)
+            if (this._activeConnection.state < NM.ActiveConnectionState.ACTIVATED)
                 return 'network-vpn-acquiring-symbolic';
             else
                 return 'network-vpn-symbolic';